import fs from 'fs';
import path from 'path';
// const config = require('./config');

export const setConfig = (data:{enabled:boolean,port:7456}) => {
    fs.writeFile(path.join(__dirname, "./config.json"), JSON.stringify(data),(err: any) => {
        if (err) {
            console.error(err)
        }else{
            console.log('写入成功')
        }
    })
}

export const  getConfig =  () => {
    try {
        console.log('获取数据')
        let data = fs.readFileSync(path.join(__dirname, "./config.json"),"utf-8");
        return JSON.parse(data);
    } catch (error) {
        console.log(error)
    }
    
}